package cn.powerone.scm.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.powerone.common.annotation.Log;
import cn.powerone.common.core.controller.BaseController;
import cn.powerone.common.core.domain.AjaxResult;
import cn.powerone.common.enums.BusinessType;
import cn.powerone.scm.domain.ScmMyCompanyInfo;
import cn.powerone.scm.service.IScmMyCompanyInfoService;
import cn.powerone.common.utils.poi.ExcelUtil;
import cn.powerone.common.core.page.TableDataInfo;

/**
 * 本公司信息Controller
 * 
 * @author PowerOne
 * @date 2025-08-05
 */
@RestController
@RequestMapping("/scm/scmMyCompanyInfo")
public class ScmMyCompanyInfoController extends BaseController
{
    @Autowired
    private IScmMyCompanyInfoService scmMyCompanyInfoService;

    /**
     * 查询本公司信息列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmMyCompanyInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScmMyCompanyInfo scmMyCompanyInfo)
    {
        startPage();
        List<ScmMyCompanyInfo> list = scmMyCompanyInfoService.selectScmMyCompanyInfoList(scmMyCompanyInfo);
        return getDataTable(list);
    }

    /**
     * 导出本公司信息列表
     */
    @PreAuthorize("@ss.hasPermi('scm:scmMyCompanyInfo:export')")
    @Log(title = "本公司信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScmMyCompanyInfo scmMyCompanyInfo)
    {
        List<ScmMyCompanyInfo> list = scmMyCompanyInfoService.selectScmMyCompanyInfoList(scmMyCompanyInfo);
        ExcelUtil<ScmMyCompanyInfo> util = new ExcelUtil<ScmMyCompanyInfo>(ScmMyCompanyInfo.class);
        util.exportExcel(response, list, "本公司信息数据");
    }

    /**
     * 获取本公司信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmMyCompanyInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scmMyCompanyInfoService.selectScmMyCompanyInfoById(id));
    }

    /**
     * 新增本公司信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmMyCompanyInfo:add')")
    @Log(title = "本公司信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScmMyCompanyInfo scmMyCompanyInfo)
    {
        return toAjax(scmMyCompanyInfoService.insertScmMyCompanyInfo(scmMyCompanyInfo));
    }

    /**
     * 修改本公司信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmMyCompanyInfo:edit')")
    @Log(title = "本公司信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScmMyCompanyInfo scmMyCompanyInfo)
    {
        return toAjax(scmMyCompanyInfoService.updateScmMyCompanyInfo(scmMyCompanyInfo));
    }

    /**
     * 删除本公司信息
     */
    @PreAuthorize("@ss.hasPermi('scm:scmMyCompanyInfo:remove')")
    @Log(title = "本公司信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scmMyCompanyInfoService.deleteScmMyCompanyInfoByIds(ids));
    }
}
